<template>
	<view>
		<view class="menus_box1">
			<view class="menus_box1_item" v-for="(item,index) in HomeNavList" :key="index" @click="Tomenus(item,index)">
				<image :src="item.image"></image>
				<view>{{item.name}}</view>
			</view>
			<!-- <view class="menus_box1_item">
				<image :src="BestImgUrl + '/index/Group 34738-2.png'"></image>
				<view>砍价成团</view>
			</view>
			<view class="menus_box1_item" @click="ToPages('/subpackageA/pages/Certification/Certification')">
				<image :src="BestImgUrl + '/index/Group 34738-3.png'"></image>
				<view>达人认证</view>
			</view>
			<view class="menus_box1_item">
				<image :src="BestImgUrl + '/index/Group 34738-4.png'"></image>
				<view>达人榜单</view>
			</view>
			<view class="menus_box1_item" @click="ToPages('/subpackageA/pages/TanDianProcess/TanDianProcess')">
				<image :src="BestImgUrl + '/index/Group 34738-5.png'"></image>
				<view>新手引导</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		name: "home-menus",
		props: {
			HomeNavList: {
				type: Array,
				default: []
			}
		},
		data() {
			return {
				BestImgUrl: app.globalData.imgurl
			};
		},
		created() {

		},
		methods: {
			ToPages(item) {
				uni.navigateTo({
					url: item
				})
			},
			//滑动菜单跳转
			Tomenus(item, idx) {
				let that = this
				console.log('点击了菜单', item, idx)
				if (item.type == 2) { //跳转tabbar类型
					uni.switchTab({
						url: item.path
					});
				} else if (item.type == 1) { //跳转nav类型
					uni.navigateTo({
						url: item.path + '?title=' + item.name + '&categoryID=' + item.id
					})
				} else if (item.type == 3) { //跳转h5url类型
					// #ifdef MP-WEIXIN || APP-PLUS
					uni.navigateTo({
						url: '/pages/Webview/Webview?url=' + encodeURIComponent(JSON.stringify(item.path))
					})
					// #endif
					// #ifdef H5
					window.location.href = item.path
					// #endif
				} else if (item.type == 4) { //跳转小程序类型
					//#ifdef APP-PLUS
					that.JumpMiniAppApp(item.original_id, item.path)
					//#endif
					// #ifdef MP-WEIXIN
					if (item.name == "粉丝福利群") {
						uni.navigateTo({
							url: item.path
						})
					} else {
						that.JumpMiniAppMini(item.appid, item.path)
					}
					// #endif
				}
			},
			//跳转小程序-微信端
			JumpMiniAppMini(aid, apath) {
				uni.openEmbeddedMiniProgram({
					appId: aid,
					path: apath,
					envVersion: 'release',
					success(res) {}
				});
			},
			//跳转小程序-APP
			JumpMiniAppApp(aid, apath) {
				plus.share.getServices(function(res) {
					var sweixin = null;
					for (var i = 0; i < res.length; i++) {
						var t = res[i];
						if (t.id == 'weixin') {
							sweixin = t;
						}
					}
					if (sweixin) {
						sweixin.launchMiniProgram({
							id: aid,
							path: apath,
							type: 0 // 微信小程序版本类型可取值： 0-正式版； 1-测试版； 2-体验版。 默认值为0
						});
					}
				}, function(res) {});
			},
		}
	}
</script>

<style lang="scss">
	.menus_box1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 26rpx;

		.menus_box1_item {
			flex: 1;
			text-align: center;

			image {
				width: 92rpx;
				height: 92rpx;
			}

			view {
				font-size: 26rpx;
				color: $zzy-text-color-333333;
			}
		}
	}
</style>